Skip to content

docs(plans): correct the TypeScript SDK plan on numbers, nesting and UUIDs - #2019

Open
coderdan wants to merge 3 commits into
nextfrom
docs/ts-sdk-plan-corrections
Open

coderdan wants to merge 3 commits into
nextfrom
docs/ts-sdk-plan-corrections

Conversation

@coderdan

@coderdan coderdan commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Three statements in docs/plans/2026-11-22-recipher-typescript-sdk.md no longer match the code. This pull request corrects them. Some of the rules come from pull requests that are still open. The plan now names them: #1775 for the number rule and the JSON nesting limit, and #1996 for UUID support.

Changes

  1. Class names. The plan used vitaminc's Vc* names for the wrapper classes. The classes were renamed in feat(recipher-js): every value type, arrays and JSON documents #1775, so the plan now uses RcDate, RcTimestamp, RcDecimal, and RcUuid, and says once where the old names come from.
  2. Numbers. The plan said an unsafe integer in a JSON document is refused. The code in feat(recipher-js): every value type, arrays and JSON documents #1775 refuses only a whole number from 2^53 up to 2^64, either side of zero. A whole number of 2^64 or more is stored as a float. A bigint is stored from -2^63 to 2^64 - 1, and refused outside that range. So a negative integer below -2^63 and above -2^64 has no form in a document. The code in feat(recipher-js): every value type, arrays and JSON documents #1775 now refuses such a number with its own message (5c78ecf) instead of asking for a bigint. The plan now lists these rules in one table. The adapter rule for integer columns is a design with no code yet. The rule now follows Dan's decision. On the way out, an integer outside the safe range comes back as a bigint, so every stored row can be read. On the way in, a whole number outside the safe range is refused.
  3. Nesting. The plan said nesting is limited to 128 levels. That is right for a value: the bridge and the frame both allow a node 128 levels below the top. A JSON document is limited to 127 levels of arrays and objects. The engine's JSON parser reads no deeper, and feat(recipher-js): every value type, arrays and JSON documents #1775 checks that limit in json(..). The plan now states both limits in one unit, and says that a Json is never inside a value tree.
  4. UUID. The plan said a RcUuid is refused until the engine adds a UUID. The engine's dynamic value model has had ValueKind::Uuid since refactor(stack-encrypt)!: each index says which kinds it takes; add the uuid kind #1929, with an equality index only. The code in feat(recipher-js): encrypt a VcUuid as the engine's UUID #1996 makes the addon encrypt a RcUuid as that kind, as a value on its own or in a record field. The table row, the Values bullet, step 2 of the build order, and the list of findings from steps 1 to 3 now say this. Each one says the SDK refuses a RcUuid until feat(recipher-js): encrypt a VcUuid as the engine's UUID #1996 merges.

Verification

I checked each statement against the code:

  • Numbers: see json_number and json_bigint in languages/typescript/packages/recipher-js/value-napi/src/scalar.rs, lines 121 to 177 on feat/recipher-js-values. The doc comment of json in crate/src/json.rs, lines 126 to 141, states the same rules.
  • Nesting: see MAX_DEPTH = 127 in crate/src/json.rs line 39, and the test "nests 127 levels deep and refuses 128" in __tests__/addon/values.test.ts line 538, both on feat/recipher-js-values. The value limit is vitaminc_aead::frame::MAX_DEPTH (128), used by value-napi/src/js.rs line 19 on next.
  • UUID: see ValueKind::Uuid and a_uuid_admits_equality_alone in packages/stack-encrypt/src/dynamic/kind.rs on next. The diff of feat(recipher-js): encrypt a VcUuid as the engine's UUID #1996 against feat(recipher-js): records through the engine's Planned #1776 removes the recipher_js::uuid refusal from crate/src/js.rs.

The plain-language checker reports no "must fix" findings on the added lines. This pull request changes a plan only, so I ran no code checks.

Related

…UUIDs

Three statements in the plan no longer match the code.

- Numbers: a JSON document refuses a whole number from 2^53 up to 2^64
  only. A whole number of 2^64 or more is stored as a float. The plan
  said that every unsafe integer is refused. The adapter rule is now
  stated for both directions, and the plan says why it differs.
- Nesting: the value bridge allows 128 levels, the frame's limit. A JSON
  document allows 127, because the engine's JSON parser reads no deeper.
  The plan gave 128 for both.
- UUID: the engine's dynamic value model has a UUID kind (#1929), and
  #1996 makes the addon encrypt a VcUuid as that kind. The plan said a
  UUID is refused until the engine adds one.
@changeset-bot

changeset-bot Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: f209a23

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI; Enforced overrides: Organization
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5daf2b4d-44d5-412b-9310-416faeca7be7

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review

@coderdan coderdan left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review of this pull request: six wording findings in the plan. One is important: the number rules leave a large negative integer with no form that works.

`bigint` in the tree. On encrypt, #1775 applies these rules:

- A whole `number` within 2^53 - 1 of zero is an integer.
- A whole `number` from 2^53 up to 2^64, on either side of zero, is

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important. The JSON number rules contradict each other for large negative values. A whole number between -2^64 and -2^63 is refused with "must be a bigint", but the bigint bullet refuses anything below -2^63. So json([-1e19]) is refused and the reader is told to use a bigint, and then json([-10000000000000000000n]) is refused as out of range. Neither form works.

Fix: say that a negative integer below -2^63 has no exact form and is refused either way, or narrow the refusal bullet to the range a bigint can hold.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0519e06. The JSON number rules now state the gap: a negative integer below -2^63 and above -2^64 has no form in a document. The number and the bigint are both refused. The plan no longer sends the reader to a bigint for that range. It says a bigint is needed only from 2^53 up to 2^64 - 1, and from -2^53 down to -2^63.

The code in #1775 does the same thing. For json([-1e19]), json_number in value-napi/src/scalar.rs returns UnsafeInteger, because the size of the number is below 2^64. For json([-10000000000000000000n]), json_bigint returns BigIntRange, because the value does not fit an i64.

The UnsafeInteger message in value-napi/src/error.rs ends with "Pass a bigint instead." That advice is wrong for this range. It is a bug in the code of #1775, not only in the wording here. I have reported it to be fixed there.

- A whole `number` from 2^53 up to 2^64, on either side of zero, is
refused. A `number` that large may have lost digits, so an integer
that large must be a `bigint`.
- A whole `number` of 2^64 or more is a float, as is any `number` with a

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor. "A whole number of 2^64 or more is a float" covers only positive numbers, though the bullet above says "on either side of zero". The plan does not say what happens to -1e20. A wasm build written from the plan could disagree with the napi build here. Fix: state what #1775's json_number does for negatives.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0519e06. The bullet now says a whole number of 2^64 or more, on either side of zero, is a float. So 1e20 and -1e20 are floats. This matches json_number in #1775 (value-napi/src/scalar.rs). The function checks the size of the number against 2^64, and its test any_other_finite_number_is_a_json_float includes -TWO_TO_64 and f64::MIN.

@@ -978,8 +999,9 @@ The core, with no EQL:
2. **Values.** The value bridge for every type in the table above,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor. Step 2 still promises "the value bridge for every type in the table above", and the table now includes VcUuid, which the same step defers until after step 3. Fix: say "every type except VcUuid", or move the UUID row out of step 2 explicitly.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0519e06. Step 2 now says "every type in the table above except VcUuid". The same step says #1996 adds VcUuid after step 3.

for a whole object follows the storage-blob converter (#1822), and
the UUID type the engine's (#1821).
for a whole object follows the storage-blob converter (#1822). The
UUID follows step 3, because a UUID field needs records: #1996 adds

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor. Step 2 says "the UUID follows step 3, because a UUID field needs records". The table and the Values bullet say a plain VcUuid value is encrypted as a UUID once #1996 lands. Fix: say whether encrypt(new VcUuid(..)) with no record works after #1996, and make the table, the bullet and step 2 agree.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0519e06. After #1996, encrypt(new VcUuid(..)) works with no record. The tests of #1996 in __tests__/addon/values.test.ts encrypt and decrypt a UUID as a value on its own, and read it back with kinds.uuid. The table row, the Values bullet, and step 2 now all say that a VcUuid encrypts as a value or in a record field. Step 2 says #1996 comes after step 3 only so that its tests can also store a UUID record field.

as a `number`. The adapter converts, because it knows the column's type: a
`number` that is a safe integer becomes a `bigint` on the way in, and a
`bigint` becomes a `number` on the way out. An unsafe integer is refused.
`bigint` becomes a `number` on the way out. An integer outside the safe

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor. The adapter rule now refuses an unsafe integer "in both directions". On the way out, that means a row whose int64 column holds a value above 2^53 (written by Go, for example) cannot be read through a Drizzle adapter. Fix: say plainly that such rows cannot be read through the adapter, or let a bigint pass through for a column typed as bigint.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0519e06, following Dan's decision. The adapter section now states the rule:

  • The column's TypeScript type is number | bigint.
  • On the way in, a number that is a safe integer becomes a bigint. A bigint is accepted as it is. A whole number outside the safe range is refused.
  • On the way out, an integer within 2^53 - 1 of zero becomes a number, and a larger integer comes back as a bigint. So the adapter can read every stored row, such as an int64 above 2^53 that Go wrote.

The section no longer says "in both directions".

decrypted value.
array and a string with an unpaired surrogate are refused. A polluted
prototype cannot add a key or see a decrypted value.
- **Nesting has two limits.** A value inside arrays and objects of values

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor. The two nesting limits are counted differently: the value limit counts levels below the top value (128), and the JSON limit counts each array or object as a level (127). The text does not say which limit applies to a JSON document inside a value. Fix: state both in the same units, and say which one refuses a JSON document placed inside a value tree.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 0519e06. Both limits now use one unit: the top value is level 0, and each array or object puts its items one level further down.

  • The bridge reads no value more than 128 levels down. That is vitaminc_aead::frame::MAX_DEPTH.
  • A JSON document has no array or object more than 126 levels down, counted from the document's own top. So at most 127 nest inside one another, as MAX_DEPTH = 127 in crate/src/json.rs of feat(recipher-js): every value type, arrays and JSON documents #1775 sets.

A Json never sits inside a value tree, so only the document's own limit applies to it. In #1775, encrypt reads a Json only as one value, or as one item of an array of values (one_value in crate/src/cipher.rs). Each item is read from level 0. A Json in an array or object any deeper is refused.

- JSON numbers: a whole number of 2^64 or more is a float on either side
  of zero. A negative integer below -2^63 and above -2^64 has no form in
  a document, because the number and the bigint are both refused.
- Adapter: an integer read from an integer column comes back as a bigint
  when it is outside the safe range, so every stored row can be read. On
  the way in, a whole number outside the safe range is still refused.
- Nesting: both limits are now counted in levels down from the top, and
  the plan says a Json is never inside a value tree.
- UUID: step 2 covers every type except VcUuid. After #1996, a VcUuid
  encrypts as a value on its own as well as in a record field.
@coderdan
coderdan marked this pull request as ready for review November 29, 2026 02:26
@coderdan
coderdan requested a review from a team as a code owner November 29, 2026 02:26

@cipherstash-agent cipherstash-agent left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review attestation

Reviewed 0519e06d · posted from Claude Code · claude-opus-5-5 · effort medium
Sources: code-review · claude-opus-5-5; mattpocock-skills:code-review standards and spec agents · model unknown; review-cross-check verify agent · model unknown
Skills: code-review, company-skills:rust-security (no Rust in the diff, so nothing applied), mattpocock-skills:code-review, company-skills:review-cross-check, company-skills:review-post

Findings (7): 1 major, 6 minor. 6 inline, 1 below.

  • docs/plans/2026-11-22-recipher-typescript-sdk.md:3 (outside diff) minor The header still says "Status: proposed. Nothing in this plan is built.", but #1774 is merged into next (8b4f20c), and this PR adds present-tense claims about #1775 and #1996. Add a revision line and update the status.

Checked and not posted: 3 findings refuted (the Json nesting wording at 628, the unqualified decrypt cell at 593, the safe-integer rule stated twice). One open question for the author: should a dated plan carry the live merge status of #1996 at all (593, 606–607)? No finding repeats the six existing threads.


Generated by Claude Code

| `VcDate("2026-11-23")` | a calendar date | `VcDate` |
| `VcDecimal("1.50")` | a decimal, with its scale | `VcDecimal` |
| `VcUuid("..")` | refused for now, with `recipher_js::uuid` | |
| `VcUuid("..")` | a universally unique identifier (UUID), from #1996, as a value or a record field. Before #1996, refused with `recipher_js::uuid` | `VcUuid` |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

major #1775, #1776 and #1996 name the wrapper classes RcDate, RcTimestamp, RcDecimal and RcUuid (value-napi/src/wrappers.js:80-83, renamed in f99259a, and uuid: kind<'uuid', RcUuid> in src/kinds.ts on #1996). No branch exports a Vc* class, so new VcUuid(..) written from this plan fails. This PR adds new VcUuid claims at 593, 601–607 and 1018–1022, on top of the stale Vc* names already at 382 and 590–611. Rename every Vc* to Rc*, and say once that vitaminc calls them Vc*.

Source: mattpocock-skills:code-review (spec agent), verified by review-cross-check · model unknown


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in f209a23. I checked the names first: value-napi/src/wrappers.js on #1775 defines RcDate, RcTimestamp, RcDecimal, and RcUuid, and next still has the Vc* names. The plan describes the API of #1775, #1776, and #1996, so every class name in the plan is now Rc*. The bullet about the wrapper classes says once that #1775 renamed them, and that vitaminc's own bridge names them Vc*.

| `VcDate("2026-11-23")` | a calendar date | `VcDate` |
| `VcDecimal("1.50")` | a decimal, with its scale | `VcDecimal` |
| `VcUuid("..")` | refused for now, with `recipher_js::uuid` | |
| `VcUuid("..")` | a universally unique identifier (UUID), from #1996, as a value or a record field. Before #1996, refused with `recipher_js::uuid` | `VcUuid` |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor The middle cell repeats the pre-#1996 refusal that the bullet at 606–607 already states, and it is much longer than every other cell in the table. Drop "Before #1996, refused with recipher_js::uuid" from the cell.

Source: mattpocock-skills:code-review (standards agent) · model unknown


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in f209a23. The cell now says "a universally unique identifier (UUID), from #1996, as a value or a record field". The refusal before #1996 is stated only in the bullet below the table.

`bigint` in the tree. On encrypt, #1775 applies these rules:

- A whole `number` within 2^53 - 1 of zero is an integer.
- A whole `number` from 2^53 up to 2^64, on either side of zero, is

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor "from 2^53 up to 2^64" reads as including 2^64, but the next bullet makes 2^64 a float, and json_number refuses only magnitude < TWO_TO_64 (scalar.rs:142-147). Write "from 2^53 up to, but not including, 2^64", to match the "2^64 - 1" style at 679.

Source: code-review · claude-opus-5-5


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in f209a23. The rules are now a table, and the text above it says each range includes both ends. The row reads "2^53 to 2^64 - 1". A number of 2^64 is in the float row, as json_number does (magnitude < TWO_TO_64 in value-napi/src/scalar.rs on #1775).

Comment on lines +674 to +675
So `1e20` and `-1e20` are floats. Any `number` with a fraction is a
float too.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor The rule list gives no rule for NaN, Infinity and -Infinity, which #1775 refuses (json_number returns NoJsonForm::NonFinite, scalar.rs:140-141). The json doc comment (crate/src/json.rs:136) does state the rule. Add "NaN and the infinities are refused."

Source: mattpocock-skills:code-review (spec agent) · model unknown


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in f209a23. The text under the table now says "NaN and the infinities are refused." For those values, json_number returns NoJsonForm::NonFinite.

- A `bigint` is written as its digits, from -2^63 to 2^64 - 1. A
`bigint` outside that range is refused.

So a positive integer from 2^53 up to 2^64 - 1 must be a `bigint`. So

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor Two sentences in a row open with "So", and the interval rules at 670–682 make the reader do the off-by-one arithmetic. A small table with columns for range, number and bigint would state them in one place.

Source: mattpocock-skills:code-review (standards agent) · model unknown


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in f209a23. The rules are now one table with three columns: the range of whole numbers, the result as a number, and the result as a bigint. Each range includes both ends, so the reader does not need to work out the edges. The two sentences that started with "So" are gone.

The table also shows a change to #1775, made in 5c78ecf. A whole number below -2^63 and above -2^64 is now refused with its own message. The message says the integer has no exact form. The message no longer asks for a bigint.

Comment on lines +686 to +687
The `eql-json-v1` case that contains `18446744073709551615` round-trips
on both builds.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor No code backs "round-trips on both builds". Nothing in recipher-js reads eql-json-v1 on #1775, #1776 or #1996, and there is no wasm build yet. Only __tests__/addon/values.test.ts:282-290 round-trips 2^64 - 1, on the native addon. The sentence now sits under "On encrypt, #1775 applies these rules", so it reads as built. Cite that test for the native build, and mark the wasm half as planned. (The edit from "holds" to "contains" here changes no meaning.)

Source: mattpocock-skills:code-review (spec and standards agents) · model unknown


Generated by Claude Code

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in f209a23. I checked this: nothing in recipher-js reads eql-json-v1, and there is no wasm build. The plan now says the native build round-trips 2^64 - 1 in the #1775 test "keeps an integer outside the safe range as a bigint" (__tests__/addon/values.test.ts). It says the wasm build is not built yet, and that the plan is for it to pass the same test and the eql-json-v1 case.

The second review of #2019 found the plan out of step with the code.

- The wrapper classes are RcDate, RcTimestamp, RcDecimal, and RcUuid in
  #1775, #1776, and #1996. The plan used vitaminc's Vc names. The plan
  now uses the Rc names, and says once that #1775 renamed them.
- The JSON number rules are now one table, with a row for each range of
  whole numbers. Each range includes both ends. The table shows the new
  refusal below -2^63. That refusal says the integer has no exact form.
  The plan also says that NaN and the infinities are refused.
- The round trip of 2^64 - 1 is tested on the native build only. The
  plan now names that test, and says the wasm build is planned.
- The UUID cell no longer repeats the refusal before #1996.
- The header now gives the status. Step 1 is built. The next steps are
  in open pull requests.
@coderdan

Copy link
Copy Markdown
Contributor Author

Reply to the finding in review 6101095709 that has no thread (the status line, outside the diff):

@coderdan

Copy link
Copy Markdown
Contributor Author

On the question in the comment above: keep the merge status in the plan. The status line and the UUID bullet get updated as #1775, #1776 and #1996 merge.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants